<html>
<head><meta charset="utf-8"><title>why does `rustc_middle` take so long? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html">why does `rustc_middle` take so long?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208168653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208168653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208168653">(Aug 27 2020 at 01:07)</a>:</h4>
<p><code>rustc_middle</code> is "only" 46k LOC according to Tokei, so why does it take so long to compile?</p>



<a name="208170778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208170778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208170778">(Aug 27 2020 at 01:45)</a>:</h4>
<p>does it expand into the same amount of HIR or MIR as other libraries? It holds some pretty abstract code.</p>



<a name="208178518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208178518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> panstromek <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208178518">(Aug 27 2020 at 05:02)</a>:</h4>
<p>I think it instantiates a lot of generic code from other crates (most of its time is spent in codegen, or at least it used to be like that), so it needs to codegen stuff that is somewhere else. You can try to run <code>cargo llvm-lines</code> on it to confirm that..</p>



<a name="208178527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208178527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> panstromek <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208178527">(Aug 27 2020 at 05:02)</a>:</h4>
<p>there's issue open for this, too <a href="https://github.com/rust-lang/rust/issues/65031">https://github.com/rust-lang/rust/issues/65031</a></p>



<a name="208201681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208201681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208201681">(Aug 27 2020 at 10:56)</a>:</h4>
<blockquote>
<p>I think it instantiates a lot of generic code from other crates</p>
</blockquote>
<p>We have a similar issue in rust-analyzer, and compilation-time gains from "not doing this" were massive</p>



<a name="208284699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208284699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208284699">(Aug 27 2020 at 22:32)</a>:</h4>
<p>can the "generic code that mostly wraps non-generic internal functions" approach be used here?</p>



<a name="208284977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208284977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208284977">(Aug 27 2020 at 22:36)</a>:</h4>
<p>I imagine that would help</p>



<a name="208284985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208284985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208284985">(Aug 27 2020 at 22:36)</a>:</h4>
<p>a lot of it could just be split into separate crates as well</p>



<a name="208285003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208285003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208285003">(Aug 27 2020 at 22:36)</a>:</h4>
<p>which would help with 'rustc_middle takes 4 GB RAM to compile' even if the actual time doesn't go down</p>



<a name="208285309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/why%20does%20%60rustc_middle%60%20take%20so%20long%3F/near/208285309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/why.20does.20.60rustc_middle.60.20take.20so.20long.3F.html#208285309">(Aug 27 2020 at 22:42)</a>:</h4>
<p>And if it's in separate crates it can likely be parallelized as well</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>